
ServerMonsters ={
    [1] = {
        name = "#ff2828Heros Serwerowy\n#fc0064Pies Punkto";
        textHeight = 0.8;
        skin = 133;
        respawnTime = {30,60};
        position = {
            [1] = {-2045.06,149.19,28.84,-0.00,0.00,140.61}, -- SF
            [2] = {-1910.98,307.92,41.05,-0.00,0.00,153.63}, -- SF
            [3] = {-2037.51,449.83,35.17,-0.00,0.00,42.08}, -- SF
            [4] = {-2421.66,989.13,45.30,-0.00,0.00,294.43}, -- SF
            [5] = {-1592.70,745.69,7.19,-0.00,0.00,302.73}, -- LV
        };
        drops = {
            [1] = {"#ffe6e6Sakiewka punktów",50,80,1,450},
            [2] = {"#fefe33Worek punktów",100,250,450,750},
            [3] = {"#2738c2Mała skrzynia punktów",300,500,750,900},
            [4] = {"#fa4b00Beczka punktów",500,1000,900,980},
            [5] = {"#fc0300Obfita skrzynia punktów",1500,3000,980,1000},
        }
    };
    
    [2] = {
        name = "#ff2828Heros Serwerowy\n#ccc000Wielka Stopa";
        textHeight = 2.4;
        skin = 132;
        respawnTime = {5,10};
        position = {
            [1] = {-2066.46509, -508.86728, 35.33594,0,0,0},
            [2] = {-2050.65576, -492.66299, 35.53435,0,0,0},
            [3] = {-2063.57056, -535.07794, 35.33594,0,0,0},
        };
        drops = {
            [1] = {"#ffe6e6Papierosy",3,9,1,300},
            [2] = {"#ffe6e6Marihuana",2,5,300,600},
            [3] = {"#ffe6e6Tytoń",5,15,600,900},
            [4] = {"#fefe33Klucz do Skrzyni Różności",1,1,900,970},
            [5] = {"#2738c2Klucz do skrzyni VIP",1,1,970,1000},
        }
    };

    [3] = {
        name = "#ff2828Heros Serwerowy\n#990000Zabójczy Królik";
        textHeight = 1.6;
        skin = 134;
        respawnTime = {5,10};
        position = {
            [1] = {-2066.46509, -508.86728, 35.33594,0,0,0},
            [2] = {-2050.65576, -492.66299, 35.53435,0,0,0},
            [3] = {-2063.57056, -535.07794, 35.33594,0,0,0},
        };
        drops = {
            [1] = {"#ffe6e6Papierosy",3,9,1,300},
            [2] = {"#ffe6e6Marihuana",2,5,300,600},
            [3] = {"#ffe6e6Tytoń",5,15,600,900},
            [4] = {"#fefe33Klucz do Skrzyni Różności",1,1,900,970},
            [5] = {"#2738c2Klucz do skrzyni VIP",1,1,970,1000},
        }
    };

    [4] = {
        name = "#ff2828Heros Serwerowy\n#000000Strażnik Pustyni Khazix";
        textHeight = 2;
        skin = 135;
        respawnTime = {5,10};
        position = {
            [1] = {-251.05,1628.30,26.20,-0.00,0.00,343.02},
            [2] = {-106.80,1908.58,15.98,-0.00,0.00,280.67},
            [3] = {347.53,2681.91,17.86,-0.00,0.00,115.08},
            [4] = {267.05,2890.12,10.71,-0.00,0.00,191.12},
            [5] = {-672.32,2709.16,70.67,-0.00,0.00,254.49},
            [6] = {-669.42,2336.49,135.70,-0.00,0.00,121.03},
            [7] = {-359.42,1592.93,76.76,-0.00,0.00,80.32},
            [8] = {793.32,1700.05,5.28,-0.00,0.00,319.71},
            [9] = {1053.32,2904.12,45.17,-0.00,0.00,199.85},
            [10] = {-1303.99,2534.27,87.74,-0.00,0.00,222.72},
            [11] = {-778.27,2422.14,157.12,-0.00,0.00,163.67},
            [12] = {-388.31,1226.66,13.96,-0.00,0.00,75.31},
        };
        drops = {
            [1] = {"#ffe6e6Papierosy",3,9,1,300},
            [2] = {"#ffe6e6Marihuana",2,5,300,600},
            [3] = {"#ffe6e6Tytoń",5,15,600,900},
            [4] = {"#fefe33Klucz do Skrzyni Różności",1,1,900,970},
            [5] = {"#2738c2Klucz do skrzyni VIP",1,1,970,1000},
        }
    };

    [5] = {
        name = "#ff2828Heros Serwerowy\n#00ff00Handlarz Mirek";
        textHeight = 1.2;
        skin = 136;
        respawnTime = {5,10};
        position = {
            [1] = {-2066.46509, -508.86728, 35.33594,0,0,0},
            [2] = {-2050.65576, -492.66299, 35.53435,0,0,0},
            [3] = {-2063.57056, -535.07794, 35.33594,0,0,0},
        };
        drops = {
            [1] = {"#ffe6e6Moonbeam",1,1,1,170},
            [2] = {"#ffe6e6Walton",1,1,170,330},
            [3] = {"#ffe6e6Manana",1,1,330,480},
            [4] = {"#ffe6e6Perennial",1,1,480,620},
            [5] = {"#ffe6e6Greenwood",1,1,620,740},
            [6] = {"#ffe6e6Fortune",1,1,740,840},
            [7] = {"#fefe33Admiral",1,1,840,910},
            [8] = {"#2738c2Landstalker",1,1,910,950},
            [9] = {"#fa4b00Club",1,1,950,980},
            [10] = {"#fc0300Huntley",1,1,980,1000},
        }
    };

}

respPiesPunkto = 0
respWielkaStopa = 0
respZabojczyKrolik = 0
respStraznikPustyniKhazix = 0
respHandlarzMirek = 0

addEventHandler("onResourceStart",resourceRoot,function()
herosTimer()
end)

addEventHandler("onPedWasted", root, function()
    if getElementData(source,"Heros") then
        local x,y,z = getElementPosition(source)
        local giftinv = createPickup(x,y,z,3,1576)
        setElementData(giftinv,"herosdrop",true)
            drop = math.random(1,1000)
            data = ServerMonsters[getElementData(source,"HerosID")]["drops"]
            if drop >= data[1][4] and drop < data[1][5] then
                award = data[1]
            elseif drop >= data[2][4] and drop < data[2][5] then
                award = data[2]
            elseif drop >= data[3][4] and drop < data[3][5] then
                award = data[3]
            elseif drop >= data[4][4] and drop < data[4][5] then
                award = data[4]
            elseif drop >= data[5][4] and drop < data[5][5] then
                award = data[5]
            elseif drop >= data[6][4] and drop < data[6][5] then
                award = data[6]
            elseif drop >= data[7][4] and drop < data[7][5] then
                award = data[7]
            elseif drop >= data[8][4] and drop < data[8][5] then
                award = data[8]
            elseif drop >= data[9][4] and drop < data[9][5] then
                award = data[9]
            elseif drop >= data[10][4] and drop < data[10][5] then
                award = data[10]
            end
        setElementData(giftinv,"name",award[1])
        setElementData(giftinv,"amount",math.random(award[2],award[3]))
        setElementData(source,"killedHeros",true)
        triggerClientEvent(root,"cmta_herosi:usuntext", root, getElementData(source,"HerosID"))
        setTimer(function()
        for i,v in pairs(getElementsByType("ped")) do
        if getElementData(v,"killedHeros") then
            if getElementData(v,"HerosID") == 1 then
                respPiesPunkto = math.random(ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][1],ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][2])
            elseif getElementData(v,"HerosID") == 2 then
                respWielkaStopa = math.random(ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][1],ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][2])
            elseif getElementData(v,"HerosID") == 3 then
                respZabojczyKrolik = math.random(ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][1],ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][2])
            elseif getElementData(v,"HerosID") == 4 then
                respStraznikPustyniKhazix = math.random(ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][1],ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][2])
            elseif getElementData(v,"HerosID") == 5 then
                respHandlarzMirek = math.random(ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][1],ServerMonsters[getElementData(v,"HerosID")]["respawnTime"][2])
            end
            destroyElement(v)
            if isTimer(herosrespawntimer) then
            else
            herosTimer()
            end
        end
        end
        end,5000,1)
    end
end)

addEventHandler( "onPickupHit", resourceRoot, function(plr)
    local isHeros = getElementData(source,"herosdrop")
    if not isHeros then return end
    if getElementData(source,"herosdrop") and not isPedInVehicle(plr) then
        if string.find(tostring(getElementData(source,"name")),"punktów") then
        local data = getElementData(plr,"player:data")
        data.points = data.points+getElementData(source,"amount")
        setElementData(plr,"player:data",data)
		end
		if string.find(tostring(getElementData(source,"name")),"punktów") then
        outputChatBox("#ccc000[Nagroda z herosa] #808080Podniesiono "..getElementData(source,"name").." ["..getElementData(source,"amount").." punktów]",plr,255,255,255,true)
        else
        outputChatBox("#ccc000[Nagroda z herosa] #808080Podniesiono #ff0000"..getElementData(source,"amount").."x "..getElementData(source,"name")..".",plr,255,255,255,true)
		end
        destroyElement(source)
	end
end)

function createMonster(idmob)    
        local ped = createPed(ServerMonsters[idmob]["skin"], ServerMonsters[idmob]["position"][resplos][1], ServerMonsters[idmob]["position"][resplos][2], ServerMonsters[idmob]["position"][resplos][3])
        setElementRotation(ped,ServerMonsters[idmob]["position"][resplos][4],ServerMonsters[idmob]["position"][resplos][5],ServerMonsters[idmob]["position"][resplos][6])
        setElementData(ped,"Heros",ServerMonsters[idmob].name)
        setElementData(ped,"HerosID",idmob)
        setElementData(ped,"HerosTextHeight",ServerMonsters[idmob].textHeight)
        triggerClientEvent("cmta_herosi:stworztext", root, ped) 
end

function herosTimer()
herosrespawntimer = setTimer(function()
if respPiesPunkto > 0 then
    respPiesPunkto = respPiesPunkto-1
elseif respPiesPunkto == 0 then
    resplos = math.random(1,5)
    respPiesPunkto = -1
    createMonster(1)
end
if respWielkaStopa > 0 then
    respWielkaStopa = respWielkaStopa-1
elseif respWielkaStopa == 0 then
    resplos = math.random(1,3)
    respWielkaStopa = -1
    createMonster(2)
end
if respZabojczyKrolik > 0 then
    respZabojczyKrolik = respZabojczyKrolik-1
elseif respZabojczyKrolik == 0 then
    resplos = math.random(1,3)
    respZabojczyKrolik = -1
    createMonster(3)
end
if respStraznikPustyniKhazix > 0 then
    respStraznikPustyniKhazix = respStraznikPustyniKhazix-1
elseif respStraznikPustyniKhazix == 0 then
    resplos = math.random(1,12)
    respStraznikPustyniKhazix = -1
    createMonster(4)
end
if respHandlarzMirek > 0 then
    respHandlarzMirek = respHandlarzMirek-1
elseif respHandlarzMirek == 0 then
    resplos = math.random(1,3)
    respHandlarzMirek = -1
    createMonster(5)
end
if (respPiesPunkto == -1) and (respWielkaStopa == -1) and (respZabojczyKrolik == -1) and (respStraznikPustyniKhazix == -1) and (respHandlarzMirek == -1) then
    killTimer(herosrespawntimer)
end
end,60,0)
end
